home *** CD-ROM | disk | FTP | other *** search
- /* This is the c file that implements the action for this screen saver.
- See GraphicsModule.c for infomation on how to write your own.
-
- First Version Andrew Armstrong
-
- © 1995 Berkeley Systems Inc.
- */
-
- /*
- ** TAB SIZE = 4 spaces
- */
-
- /*
- ** TO DO:
- ** * handle the case in _Draw where the rendering could fail. Do we View_Sync()?
- ** * Multiple monitors
- ** * Make the pixmap point right to the screen for Apple HD Accel
- ** * Make the sliders work in demo mode
- ** * check for the libraries
- ** * check version of the libraries
- ** * Handle case where they are not installed (draw error message with WWW Address)
- **
- ** FUTURE DIRECTIONS
- ** * cutsie-ass names on the sliders
- */
-
- #if 0
- #pragma mark INCLUDES
- #endif
-
- /*
- ** PROJECT INCLUDES
- */
- #include "QD3DErrorModule.h"
- #include "Q3ADUtilities.h"
- #include "PICTSprite.h"
-
- /*
- ** ANSI INCLUDES
- */
- #include <assert.h>
- #include <stdlib.h>
-
- /*
- ** MAC INCLUDES
- */
- #include <Quickdraw.h>
- #include <QDOffscreen.h>
- #include <Memory.h>
-
- #if 0
- #pragma mark CONSTANTS
- #endif
-
- /*
- ** CONSTANTS
- */
-
- #define mPICTAnimationBaseID 128
- #define mPICTAnimationNumberOfFaces 40
-
- #if 0
- #pragma mark GLOBALS
- #endif
-
- /*
- ** GLOBALS
- */
-
-
- typedef struct iTQ3ADErrorModule
- {
- long drewHeaders;
- PicHandle wwwAddressPICT;
- TPICTSprite *sprite;
- CGrafPtr destPort;
- Rect destRect;
-
- } iTQ3ADErrorModule;
-
-
-
-
- #if 0
- #pragma mark PRIVATE FUNCTION DECLARATIONS
- #endif
-
- /*
- ** PRIVATE FUNCTIONS
- */
- static TQ3Status iQ3ADErrorModule_ZeroOut(
- TQ3ADErrorModule *ioModule);
-
-
- #if 0
- #pragma mark -
- #endif
-
- /*===========================================================================*\
- *
- * Routine: Q3ADErrorModule_New()
- *
- * Comments:
- *
- \*===========================================================================*/
-
- TQ3ADErrorModule **Q3ADErrorModule_New(GMParamBlockPtr params)
- {
- TQ3Status status = kQ3Success;
-
- TQ3ADErrorModule **outModule;
-
- Rect monitorRect;
- Rect rotatingQD3DRect;
- long halfWidth, halfHeight;
-
- #define mRotatingQD3D_Width 256
- #define mRotatingQD3D_Height 256
-
- assert(params);
-
- mBailIfNULL_(outModule = (TQ3ADErrorModule **)NewHandle(sizeof(TQ3ADErrorModule)));
- HLock((Handle) outModule);
-
- mBailIfNot_(iQ3ADErrorModule_ZeroOut(*outModule));
-
- /*
- ** Set up the destination rect
- */
-
- /*
- ** Make a base rect which is normalized and which has the dimensions
- ** that we want
- */
- SetRect(
- &rotatingQD3DRect,
- 0,
- 0,
- mRotatingQD3D_Width - 1,
- mRotatingQD3D_Height - 1);
-
- /*
- ** Find out the optimal monitor to place it
- */
-
- monitorRect = Q3ADUtility_GetRectOfBestMonitor(params->monitors);
-
- /*
- ** Find the center of that monitor
- */
- halfWidth = (monitorRect.right - monitorRect.left) * 0.5;
- halfHeight = (monitorRect.bottom - monitorRect.top) * 0.5;
-
- /*
- ** place our rect there
- */
- OffsetRect(
- &rotatingQD3DRect,
- halfWidth - (mRotatingQD3D_Width / 2),
- halfHeight - (mRotatingQD3D_Height / 2));
-
-
- /*
- ** We align this on byte boundaries because CopyBits can blit it faster.
- ** We do this so that if anything, it shrinks the rect a bit to
- ** make sure it stays on the screen.
- */
- /* SetRect(
- &alignedRect,
- rotatingQD3DRect.left % kLongSize,
- kLongSize - (rotatingQD3DRect.top % kLongSize),
- kLongSize - (rotatingQD3DRect.right % kLongSize),
- rotatingQD3DRect.bottom % kLongSize);
- */
-
-
- mBailIfNULL_((**outModule).sprite = PICTSprite_New(
- mPICTAnimationBaseID,
- mPICTAnimationNumberOfFaces,
- 0,
- (CGrafPtr)params->qdGlobalsCopy->qdThePort,
- &rotatingQD3DRect));
-
- (**outModule).destRect = monitorRect;
- (**outModule).destPort = (CGrafPtr)params->qdGlobalsCopy->qdThePort;
-
- /*
- ** HTTP://QUICKDRAW3D.APPLE.COM
- */
-
- /* mBailIfNULL_(currentPicture = GetPicture(outPICTSprite->basePictureID));
-
- currentPicture_Height = (**currentPicture).picFrame.bottom -
- (**currentPicture).picFrame.top;
- currentPicture_Width = (**currentPicture).picFrame.right -
- (**currentPicture).picFrame.left;
- */
- bail:
-
- if (status == kQ3Failure)
- if(outModule) {
- Q3ADErrorModule_Dispose(outModule);
- outModule = NULL;
- }
-
- return outModule;
- }
-
-
-
- /*===========================================================================*\
- *
- * Routine: Q3ADErrorModule_Dispose()
- *
- * Comments:
- *
- \*===========================================================================*/
-
- TQ3Status Q3ADErrorModule_Dispose(TQ3ADErrorModule **inModule)
- {
- assert(inModule);
-
- if ((**inModule).sprite)
- PICTSprite_Dispose((**inModule).sprite);
-
- if ((**inModule).wwwAddressPICT)
- ReleaseResource((Handle)(**inModule).wwwAddressPICT);
-
- DisposeHandle((Handle)inModule);
-
- return kQ3Success;
- }
-
-
-
- /*===========================================================================*\
- *
- * Routine: Q3ADErrorModule_Draw()
- *
- * Comments:
- *
- \*===========================================================================*/
-
- TQ3Status Q3ADErrorModule_Draw(
- TQ3ADErrorModule *inModule)
- {
- TQ3Status status = kQ3Success;
- static long lastTickCount = 0;
- long currentTicks = TickCount();
-
-
-
- if (currentTicks > lastTickCount + 2)
- {
- PICTSprite_Draw(inModule->sprite);
- lastTickCount = currentTicks;
- }
- bail:
-
- return status;
- }
-
-
-
- /*===========================================================================*\
- *
- * Routine: iQ3ADErrorModule_ZeroOut()
- *
- * Comments:
- *
- \*===========================================================================*/
-
- TQ3Status iQ3ADErrorModule_ZeroOut(TQ3ADErrorModule *inModule)
- {
- assert(inModule);
-
- inModule->drewHeaders = FALSE;
- inModule->sprite = NULL;
- inModule->destPort = NULL;
-
- inModule->wwwAddressPICT = NULL;
-
- inModule->destRect.top =
- inModule->destRect.bottom =
- inModule->destRect.left =
- inModule->destRect.right = 0;
-
- return kQ3Success;
- }
-
-
-
-